package com.kaishengit.action;

import java.util.List;
import java.util.Map;

import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.convention.annotation.Results;
import org.springframework.beans.factory.annotation.Autowired;

import com.kaishengit.pojo.Atmessage;
import com.kaishengit.pojo.Message;
import com.kaishengit.pojo.Project;
import com.kaishengit.pojo.Task;
import com.kaishengit.pojo.User;
import com.kaishengit.service.AtmessageService;
import com.kaishengit.service.MessageService;
import com.kaishengit.service.ProjectService;
import com.kaishengit.service.TaskService;

@Results({
	@Result(name="list",location="proj.action",type="redirectAction")
})
public class ProjAction extends BaseAction{

	private static final long serialVersionUID = 1L;
	private Project project;
	private ProjectService prijectService;
	private List<Task> taskList;
	private TaskService taskService;
	private int id;
	private MessageService messageService;
	private List<Message> messageList;
	private Message message;
	private User user;
	private int p;
	private List<Atmessage> atmessageList;
	private AtmessageService atmessageService;
	
	public String list() throws Exception {
		project = prijectService.findById(id);
		putInSession("project", project);
		user = (User) getFromSession("user");
		taskList = taskService.findById((User)getFromSession("user"),project);
		messageList = messageService.findByProject(project,p);
		atmessageList = atmessageService.findByProjAndUser(user,project);
		return "success";
	}
	
	public Project getProject() {
		return project;
	}

	public void setProject(Project project) {
		this.project = project;
	}

	

	public ProjectService getPrijectService() {
		return prijectService;
	}

	@Autowired
	public void setPrijectService(ProjectService prijectService) {
		this.prijectService = prijectService;
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public List<Task> getTaskList() {
		return taskList;
	}

	public void setTaskList(List<Task> taskList) {
		this.taskList = taskList;
	}
	
	@Autowired
	public void setTaskService(TaskService taskService) {
		this.taskService = taskService;
	}

	public List<Message> getMessageList() {
		return messageList;
	}

	public void setMessageList(List<Message> messageList) {
		this.messageList = messageList;
	}

	public Message getMessage() {
		return message;
	}

	public void setMessage(Message message) {
		this.message = message;
	}
	@Autowired
	public void setMessageService(MessageService messageService) {
		this.messageService = messageService;
	}

	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	public int getP() {
		return p;
	}

	public void setP(int p) {
		this.p = p;
	}

	public void setApplication(Map<String, Object> arg0) {
	}

	public List<Atmessage> getAtmessageList() {
		return atmessageList;
	}

	public void setAtmessageList(List<Atmessage> atmessageList) {
		this.atmessageList = atmessageList;
	}

	@Autowired
	public void setAtmessageService(AtmessageService atmessageService) {
		this.atmessageService = atmessageService;
	}
	
}
